package io;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyDemo2 {
    /*
    利用缓冲区复制文件
     */
    public static void main(String[] args) throws IOException {
        FileInputStream in = new FileInputStream("./klxm.jpg");
        FileOutputStream out = new FileOutputStream("./klxm_cp.jpg");
        long t1 = System.currentTimeMillis();
        byte[] bytes = new byte[1024*8];
        int n;
        while ((n = in.read(bytes))!= -1){
            out.write(bytes,0,n);
        }
        in.close();
        out.close();
        long t2 = System.currentTimeMillis();
        System.out.println("复制完毕,耗时："+(t2-t1));
    }
}
